Release 10.1A: OpenEdge Data Management:
DataServer for Microsoft SQL Server
Writing queries for performance
This section provides a collection of tips and guidelines to follow when writing queries. For example, a query that processes a large number of rows performs best if it uses
NO–LOCK, lookahead cursors, a large cache size, and a small field list.These tips and guidelines might improve the performance of your DataServer applications. To assess the usefulness of a particular suggestion, apply it, then use the
DEBUGdiagnostic options to gather statistics on how your application runs:
- Use
FOREACH,GET, andOPENQUERYstatements rather thanFINDstatements, which generally perform more slowly. Consider using theFORFIRSTstatement instead ofFINDFIRST.The only exception is that
FINDLASTis faster thanGETLAST. This is becauseGETLASTcauses the client to process all of the records; theFINDLASTstatement allows the server to retrieve the last record.- Use field lists.
- Use the
QUERY–TUNINGoptions.- Use lookahead cursors.
- Use
NO–LOCKwhere possible.- Avoid specifying lock upgrades. Instead, allow the DataServer and the MSS data source to handle lock upgrades.
- Do not ask for a particular ordering of results with
USE–INDEXorBYclauses unless your application requires it. Instead, allow the DataServer and the MSS data source to determine the most efficient index (if any) for processing a query and avoid the overhead of sorting results.- If you use a
BYclause that will sort a large amount of data, make sure a corresponding index exists in your data source to make sorting efficient. In some cases it may also be desirable to have indexes over columns used inWHEREclause selection criteria.- For aggregates, use either the
RUN–STORED–PROCEDUREsend–sql–statementsyntax or a Progress SQL statement. If you use a Progress SQL statement with a cursor, declare the cursor read-only.- When you test for the existence of a record, use the
CAN–FINDFIRSTfunction, which does not retrieve the record if the DataServer passes the entireWHEREclause to the MSS data source for processing. However, avoid nestingCAN–FINDfunctions.- Avoid using the
RECIDfunction. Instead, use theROWIDfunction.See the "Analyzing performance" section for information on collecting statistics.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |